home *** CD-ROM | disk | FTP | other *** search
Text File | 2007-04-11 | 33.4 KB | 1,102 lines |
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * Document.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- if (!IS.isModuleInitialized("IS.NOF.HTML.Document"))
- {
-
- /****h* NOF_JavaScript_Library/NOF.HTML.Container
- *
- * NAME
- * NOF.HTML.Container
- *
- * DESCRIPTION
- *
- ****/
-
- /**
- * constructor
- **/
- function NOF_HTML_Container(_doc){
- this.__proto__ = NOF_HTML_Container.prototype;
-
- this.doc = _doc;
- this.components = new Array();
- }
- {
- var method = NOF_HTML_Container.prototype;
- method.addComponent = function ( comp ){};
- method.removeComponent = function ( comp ){};
- method.getComponents = function (){};
-
- /**
- * function getDocument
- *
- * convenience method, in case somebody wants to access the document directly
- * @return the document itself
- */
- method.getRawDoc = function () {
- return this.doc;
- }
-
- /**
- * function write
- *
- * convenience method, in case somebody wants to write to the document
- */
- method.write = function (str) {
- return this.doc.write(str);
- }
- }
- HTML.__proto__.Container = NOF_HTML_Container;
- //NOF.__proto__.HTMLContainer = NOF_HTML_Container;
-
-
- /****h* NOF_JavaScript_Library/NOF.HTML.Document
- *
- * NAME
- * NOF.HTML.Document
- *
- * DESCRIPTION
- *
- * Html document, based on DOM used in IE and Netscape Gecko
- *
- ****/
- /**
- * constructor
- **/
- function NOF_HTML_Doc( _doc ){
- this.__proto__ = NOF_HTML_Doc.prototype;
- this.SUPER ( _doc );
-
- this.propertyMap = new Array();
- }
- NOF_HTML_Doc.inherits ( NOF.HTML.Container )
- {
- //var member = NOF_HTML_Doc.prototype;
-
- var method = NOF_HTML_Doc.prototype;
-
- /**
- * function getElementType
- *
- * find out the type of the element based in the element
- * @param element the html doc element
- * @return the type of the element: 'text','textarea',
- * 'multiple-select','radio','checkbox' etc in lowercase
- */
- method.getElementType = function (element) {
- if (element != null) {
- var elementType = element.type;
- if (elementType != null) {
- elementType = elementType.toLowerCase();
- }
- else {
- if (element.length > 0) {
- elementType = element[0].type;
- }
- if (elementType == null) {
- elementType = element.nodeName;
- }
- }
- }
- else {
- elementType = null;
- }
- return elementType.toLowerCase();
- }
-
- /**
- * function getElementById
- *
- * find out the element based on the element id
- * @param elementId the id of the html doc element
- * @return element: the html element itself
- */
- method.getElementById = function (elementId) {
- return this.doc.all[this.getProperty(elementId)];
- }
-
- /**
- * setElementAttribute
- *
- * Sset any attribute what a dom element can have
- * @param id the id of the html doc element
- * @param attrName the name of the attribute to set
- * @param attrValue the value of the attribute
- **/
- method.setElementAttribute = function (id, attrName, attrValue) {
- var element = this.getElementById (id);
-
- if ((attrName != null && attrName.length > 0) && (element != null)) {
- if (element.attributes[attrName] != null) {
- element.attributes[attrName].value= attrValue;
- return true
- }
- }
- return false
- }
-
-
- /**
- * function setElementValue
- *
- * set the value for an html element
- * @param id the id of the html doc element
- * @param value the value of the html doc element
- * @return result: true or false based on setvalue was succesfull or not
- */
- method.setElementValue = function (id, value) {
- var element = this.getElementById (id);
- var elementType = this.getElementType(element);
- if (elementType == null) {
- return false;
- }
-
- if (elementType == 'checkbox') {
- return this.setCheckBoxGroupValue(element, value);
- }
- else if (elementType == 'radio') {
- return this.setRadioGroupValue(element, value);
- }
- else if (elementType.indexOf('select',0) == 0) {
- return this.setSelectValues(element, value);
- }
- else if (elementType == 'span') {
- return this.setSpanInnerText(element, value);
- }
- else if (elementType == 'label') {
- return this.setSpanInnerText(element, value);
- }
- else {
- element.value = value;
- return true;
- }
- return false;
- }
-
- /**
- * function getElementValue
- *
- * set the value for an html element
- * @param id the id of the html doc element
- * @return result: the value of the html doc element
- */
- method.getElementValue = function (id) {
- var element = this.getElementById (id);
- var elementType = this.getElementType(element);
-
- if (elementType == 'checkbox') {
- return this.getCheckBoxGroupValue(element);
- }
- else if (elementType == 'radio') {
- return this.getRadioGroupValue(element);
- }
- else if (elementType.indexOf('select',0) == 0) {
- return this.getSelectValues(element);
- }
- else if (elementType == 'span') {
- return this.getSpanInnerText(element);
- }
- else if (elementType != null) {
- return element.value;
- }
- return null;
- }
-
- /**
- * function cleanElementValue
- *
- * clean the value for an html element
- * @param id the id of the html doc element
- * @param
- * @return result: true or false based on clean value was succesfull or not
- */
- method.cleanElementValue = function (id) {
- var element = this.getElementById (id);
- var elementType = this.getElementType(element);
- if (elementType == null) {
- return false;
- }
-
- if (elementType == 'checkbox') {
- return this.uncheckCheckBoxGroupValue(element);
- }
- else if (elementType == 'radio') {
- return this.uncheckRadioGroupValue(element);
- }
- else if (elementType.indexOf('select',0) == 0) {
- return this.clearSelectValues(element);
- }
- else if (elementType == 'span') {
- this.setSpanInnerText(element, "");
- }
- else {
- element.value = "";
- return true;
- }
- return false;
- }
-
- /**
- * function focusElement
- *
- * set the focus on this element
- * @param id the id of the html doc element
- */
- method.focusElement = function ( id ) {
- var element = this.getElementById (id);
- if (element != null) {
- element.focus ();
- }
- }
-
- /**
- * function enableElement
- *
- * set the html element enabled (disabled = false)
- * @param id the id of the html doc element
- */
- method.enableElement = function (id) {
- var element = this.getElementById (id);
- if (element != null) {
- element.disabled = false;
- }
- }
-
- /**
- * function disableElement
- *
- * set the html element disabled (disabled = true)
- * @param id the id of the html doc element
- */
- method.disableElement = function (id) {
- var element = this.getElementById (id);
- if (element != null) {
- element.disabled = true;
- }
- }
-
- /**
- * function setElementItemAt
- *
- * set one element item (element has to be a container: radiogroup,checkboxgroup,select)
- * if element exists in the list, its values will be updated. otherwise element will be
- * added to the list
- *
- * @param id the id of the html doc element
- * @param item the items for this element (can be type of array)
- * For select could be: [options.text,options.value] or value
- * @param index the index of the item in the elements item list
- * @return result: true or false based on setelements was succesfull or not
- */
- method.setElementItemAt = function (id, item, index) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- // return this.setCheckBoxGroupList(element, listItems);
- return false;
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.setRadioGroupList(element, listItems);
- return false;
- }
- if (elementType.indexOf('select') == 0) {
- return this.setSelectListItemAt(element, item, index);
- }
- return false;
- }
-
- /**
- * function setElementItem
- *
- * set one element item (element has to be a container: radiogroup,checkboxgroup,select)
- * if element exists in the list, its values will be updated. otherwise element will be
- * added to the list
- *
- * @param id the id of the html doc element
- * @param item the items for this element (can be type of array)
- * For select could be: [options.text,options.value] or value
- * @return result: true or false based on setelements was succesfull or not
- */
- method.setElementItem = function (id, item) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- // return this.setCheckBoxGroupList(element, listItems);
- return false;
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.setRadioGroupList(element, listItems);
- return false;
- }
- if (elementType.indexOf('select') == 0) {
- return this.setSelectListItem(element, item);
- }
- return false;
- }
-
- /**
- * function setElementItems
- *
- * set the element items (element has to be a container: radiogroup,checkboxgroup,select
- * @param id the id of the html doc element
- * @param listItems the items for this element (can be type of array)
- * For select could be: [(options.text,options.value),{options.text,options.value),etc] or
- * [value, value,...]
- * @return result: true or false based on setelements was succesfull or not
- */
- method.setElementItems = function (id, listItems) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- // return this.setCheckBoxGroupList(element, listItems);
- return false;
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.setRadioGroupList(element, listItems);
- return false;
- }
- if (elementType.indexOf('select') == 0) {
- //NOF.util_logging_ConsoleLogger_global.info ('set select list');
- return this.setSelectList(element, listItems);
- }
- return false;
- }
-
- /**
- * function getElementItemAt
- *
- * return item from the element items (element has to be a container: radiogroup,checkboxgroup,select)
- * with the specified index
- * @param id the id of the html doc element
- * @index the index of the item in the array
- * @return item or null if index not in range
- * For select item is [options.text,options.value]
- */
- method.getElementItemAt = function (id, index) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- // return this.getCheckBoxElements(element);
- return null;
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.getRadioGroupElements(element);
- return null;
- }
- if (elementType.indexOf('select') == 0) {
- return this.getSelectListItemAt(element, index);
- }
- return null;
- }
-
- /**
- * function getElementItem
- *
- * return an item from the element items(element has to be a container: radiogroup,checkboxgroup,select)
- * @param id the id of the html doc element
- * @param key the key to look for in the items list (in select element, key is the option.value field)
- * @return parameter for this item or null if not succeeded
- *
- * return parameter for select is the option.text, while search key is the option.value
- *
- */
- method.getElementItem = function (id, key) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- // return this.getCheckBoxElements(element);
- return null;
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.getRadioGroupElements(element);
- return null;
- }
- if (elementType.indexOf('select') == 0) {
- return this.getSelectListItem(element, key);
- }
- return null;
- }
-
- /**
- * function getElementItems
- *
- * return the element items (element has to be a container: radiogroup,checkboxgroup,select)
- * @param id the id of the html doc element
- * @return listItems the items for this element or null if not succeeded
- */
- method.getElementItems = function (id) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- // return this.getCheckBoxElements(element);
- return null;
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.getRadioGroupElements(element);
- return null;
- }
- if (elementType.indexOf('select') == 0) {
- return this.getSelectList(element);
- }
- return null;
- }
-
- /**
- * function isInElementItemList
- *
- * check if item is in between element items (element has to be a container: radiogroup,checkboxgroup,select)
- * @param id the id of the html doc element
- * @param cmpItem the item to compare
- * @param isCaseSensitive true/false
- * @return result: true or false depending if element was found or not
- */
- method.isInElementItemList = function (id, cmpItem, isCaseSensitive) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- // return this.isInCheckBoxGroupList(element, newItem, isCaseSensitive);
- return false;
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.isInRadioGroupList(element, newItem, isCaseSensitive);
- return false;
- }
- if (elementType.indexOf('select') == 0) {
- //NOF.util_logging_ConsoleLogger_global.info ('select in list?');
- return this.isInSelectList(element, cmpItem, isCaseSensitive);
- }
- return false;
- }
-
- /**
- * function addElement
- *
- * add a new item to the element item list (element has to be a container: radiogroup,checkboxgroup,select)
- * @param id the id of the html doc element
- * @param newItem the new item for this element (can be type of array)
- * For select could be: [value,displayName] or value
- * @return result: true or false depending if element was added or not
- */
- method.addElement = function (id, newItem) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- // return this.addCheckBoxElement(element, newItem);
- return false;
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.addRadioGroupElement(element, newItem);
- return false;
- }
- if (elementType.indexOf('select') == 0) {
- return this.addSelectElement(element, newItem);
- }
- return false;
- }
-
- /**
- * function removeElements
- *
- * remove items from the element item's list (element has to be a container: radiogroup,checkboxgroup,select)
- * @param id the id of the html doc element
- * @param itemsToRemo the items to remove
- * @return result: true or false depending if elements were removed or not
- */
- method.removeElements = function (id, itemsToRemove) {
- var element = this.getElementById(id);
- var elementType = this.getElementType(element);
- if (elementType == 'checkbox') {
- // not implemented yet
- return this.removeCheckBoxElements(element, itemsToRemove);
- }
- if (elementType == 'radio') {
- // not implemented yet
- // return this.removeCheckBoxElements(element, itemsToRemove);
- return false;
- }
- if (elementType.indexOf('select') == 0) {
- return this.removeSelectElements(element, itemsToRemove);
- }
- return false;
- }
-
- /**
- * function initialize
- *
- * initialize html from resource file
- * @param resource object
- */
- method.initialize = function (resource) {
- this.parseAndInitializeDoc (resource);
- /*
- var pNode = this.doc;
- this.parseAndInitializeTree(pNode, resource, "");
- */
- }
-
- method.parseAndInitializeDoc = function (/* NOF.HTML.App */ resource) {
- var len = this.doc.all.length;
- for (var i = 0; i < len; i++) {
- var pNode = this.doc.all[i];
-
- if (pNode.nodeName == 'SPAN') {
- var id = pNode.attributes.id;
- if (id != null) {
- var label = resource.getResourceProperty(id.value);
- if (label != null) {
- pNode.innerHTML = label;
- }
- }
- }
- else if (pNode.nodeName == 'LABEL') {
- var id = pNode.attributes.id;
- if (id != null) {
- var label = resource.getResourceProperty(id.value);
- if (label != null) {
- pNode.innerHTML = label;
- }
- }
- }
- else if (pNode.nodeName == 'INPUT' && pNode.type == 'button') {
- if (pNode.attributes.id) {
- var value = pNode.attributes.id.value;
- if (value != null) {
- var label = null;
- label = resource.getResourceProperty(value);
- if (label != null) {
- pNode.attributes.value.value = label;
- }
- }
- }
- }
- else if (pNode.nodeName == 'SELECT') {
- if (pNode.attributes.id) {
- var list = pNode.options;
- if (list.length > 0) {
- var id = pNode.attributes.id.value;
- for (var j=0;j<list.length;j++) {
- var label = null;
- label = resource.getResourceProperty(id + "." + list[j].value);
- if (label != null) {
- list[j].text = label;
- }
- }
- }
- }
- }
- }
- }
-
- method.parseAndInitializeTree = function (/* HTML DOM Node */ pNode,
- /* NOF.HTML.App */ resource,
- tabStr) {
- // first check for id if not a resuorce
- if (pNode.childNodes.length == 0) {
- if (pNode.nodeName == 'SPAN') {
- var id = pNode.attributes.id;
- if (id != null) {
- var label = resource.getResourceProperty(id.value);
- if (label != null) {
- var textNode = this.doc.createTextNode(label);
- pNode.appendChild(textNode);
- }
- }
- }
- else if (pNode.nodeName == 'INPUT' && pNode.type == 'button') {
- if (pNode.attributes.id) {
- var value = pNode.attributes.id.value;
- if (value != null) {
- var label = null;
- label = resource.getResourceProperty(value);
- if (label != null) {
- pNode.attributes.value.value = label;
- }
- }
- }
- }
- }
- else {
- for (var i=0; i < pNode.childNodes.length; i++) {
- this.parseAndInitializeTree(pNode.childNodes[i], resource, tabStr + " ");
- }
- }
- }
-
-
- /** method localizeNode
- * Inserts strings coresponding to tag's id attributes from
- * <code>resource</code> object.
- */
- method.localizeNode = function (/*HTML Node*/ pNode,
- /*NOF.UTIL.ResourceBundle*/ resource) {
-
- if (pNode.childNodes.length == 0) {
- if (pNode.nodeName == 'SPAN' || pNode.nodeName == 'LABEL') {
- var id = pNode.attributes.id;
- if (id != null) {
- var label = resource.getProperty(id.value);
- if (label != null) {
- var textNode = this.doc.createTextNode(label);
- pNode.appendChild(textNode);
- }
- }
- }
- else if (pNode.nodeName == 'INPUT' && pNode.type == 'button')
- if (pNode.attributes.id) {
- var value = pNode.attributes.id.value;
- if (value != null) {
- var label = null;
- label = resource.getProperty(value);
- if (label != null)
- pNode.attributes.value.value = label;
- }
- }
-
- } else {
- for (var i=0; i < pNode.childNodes.length; i++)
- this.localizeNode(pNode.childNodes[i], resource);
- }
- }
-
- // private functions
- method.setCheckedFields = function (element, valueSet) {
- var counter = 0;
- if (element.length) {
- for (var i=0;i<element.length;i++){
- if (valueSet[element[i].value] == true) {
- element[i].checked = true;
- counter++;
- }
- }
- }
- else {
- if (valueSet[element.value] == true) {
- element.checked = true;
- counter++;
- }
- }
- if (counter > 0)
- return true;
- // no element found to set
- return false;
- }
-
- method.setRadioGroupValue = function (element, value) {
- var valueSet = new Array();
- valueSet[value] = true;
- return this.setCheckedFields(element, valueSet);
- }
-
- method.setCheckBoxGroupValue = function (element, value) {
- var valueSet = new Array();
- if (typeof value != 'string') {
- for (var i=0;i<value.length;i++) {
- valueSet[value[i]] = true;
- }
- }
- else {
- valueSet[value] = true;
- }
- return this.setCheckedFields(element, valueSet);
- }
-
- method.setSelectedFields = function (element,valueSet, valueSetLength) {
- if (element.options.length > 0) {
- var counter = 0;
- for (var i=0;i<element.options.length;i++){
- if (valueSet[element.options[i].value] == true) {
- element.options[i].selected = true;
- counter++;
- }
- }
- if (counter == valueSetLength)
- return true;
- return false;
- }
- return false;
- }
-
- method.setSelectValues = function (element, value) {
- var valueSet = new Array();
- var valueSetLength = 1;
- if (typeof value != 'string') {
- if ((value.length > 1) && (element.type != 'select-multiple')) {
- return false;
- }
- for (var i=0;i<value.length;i++) {
- valueSet[value[i]] = true;
- }
- valueSetLength = value.length;
- }
- else {
- valueSet[value] = true;
- }
- return this.setSelectedFields(element, valueSet, valueSetLength);
- }
-
- method.setSelectIndex = function (elementId, index) {
- var element;
- if ( typeof elementId == "string" )
- element = this.getElementById(elementId);
- else
- return;
-
- element.selectedIndex = index;
- }
-
-
- method.setSpanInnerText = function (element, newLabel) {
- var newTextNode = this.doc.createTextNode(newLabel);
- if (element.childNodes.length > 0) {
- element.childNodes[0].replaceNode (newTextNode);
- }
- else {
- element.appendChild(newTextNode);
- }
- return true;
- }
-
- method.getCheckedFieldValues = function (element, stopAtFirst) {
- var values = new Array(); j = 0;
- if (element.length) {
- for (var i=0;i<element.length;i++){
- if (element[i].checked == true) {
- values[j] = element[i].value;
- if (stopAtFirst) {
- return values;
- }
- j++;
- }
- }
- }
- else {
- if (element.checked == true) {
- values[j] = element.value;
- }
- }
- return values;
- }
-
- method.getRadioGroupValue = function (element) {
- return this.getCheckedFieldValues(element, true);
- }
-
- method.getCheckBoxGroupValue = function (element) {
- return this.getCheckedFieldValues(element, false);
- }
-
- method.getSelectValues = function (element) {
- if (element.options && element.options.length > 0) {
- var values = new Array(); j = 0;
- for (var i=0;i<element.options.length;i++){
- if (element.options[i].selected == true) {
- values[j] = element.options[i].value;
- if (element.type != 'select-multiple') {
- return values;
- }
- j++;
- }
- }
- return values;
- }
- return null;
- }
-
- method.getSpanInnerText = function (element) {
- if (element.childNodes.length > 0) {
- return element.childNodes[0].nodeValue;
- }
- return null;
- }
-
- method.setSelectListItemAt = function (element, item, idx) {
- var optionTags = this.getSelectOptionTags (item);
- var listElements = element.options;
- var newOption = new Option (optionTags[0], optionTags[1]);
- listElements[idx] = newOption;
- return true;
- }
-
- method.setSelectListItem = function (element, item) {
- var optionTags = this.getSelectOptionTags (item);
-
- var listElements = element.options;
- var idx = listElements.length;
- for (var i=0;i<idx;i++) {
- if (listElements[i].value == optionTags[1]) {
- listElements[i].text = optionTags[0];
- return true;
- }
- }
- var newOption = new Option (optionTags[0], optionTags[1]);
- listElements[idx] = newOption;
- return true;
- }
-
- method.setSelectList = function (element, listItems) {
- var displayName = "";
- var value = "";
- var listElements = element.options;
- listElements.length = 0;
- var idx = listItems.length;
- for (var i=0;i<idx;i++) {
- this.addOptionToSelect(listElements, listItems[i]);
- }
- return true;
- }
-
- method.addOptionToSelect = function (sElement, oParams){
- var optionTags = this.getSelectOptionTags ( oParams );
- var oOption = this.doc.createElement("OPTION");
- sElement.options.add( oOption );
- oOption.innerText = optionTags[0];
- oOption.value = optionTags[1];
- }
-
- method.isInSelectList = function (element, cmpItem, isCaseSensitive) {
- var listElements = element.options;
- var idx = listElements.length;
- if (idx > 0) {
- if (!isCaseSensitive) {
- cmpItem = cmpItem.toLowerCase();
- }
- for (var i=0;i<idx;i++) {
- var listItem = listElements[i].value;
- if (!isCaseSensitive) {
- listItem = listItem.toLowerCase();
- }
- if (listItem == cmpItem) {
- return true;
- }
- }
- }
- return false;
- }
-
- method.getSelectListItemAt = function (element, index) {
- var listElements = element.options;
- if (index >= listElements.length)
- return null;
-
- var item = new Array(2);
- item[0] = listElements[index].text;
- item[1] = listElements[index].value;
- return item;
- }
-
- method.getSelectListItem = function (element, value) {
- var listElements = element.options;
- var idx = listElements.length;
- var listItems = new Array(idx);
- for (var i=0;i<idx;i++) {
- if (value == listElements[i].value) {
- return listElements[i].text;
- }
- }
- return null;
- }
-
- method.getSelectListItemIndex = function (element, value, text ) {
- var listElements = element.options;
- var idx = listElements.length;
- var listItems = new Array( idx );
- for ( var i=0; i < idx; i++ ) {
- if ( value == listElements[i].value || text == listElements[i].text ) {
- return i;
- }
- }
- return -1;
- }
-
- method.getSelectList = function (element) {
- var listElements = element.options;
- var idx = listElements.length;
- var listItems = new Array(idx);
- for (var i=0;i<idx;i++) {
- listItems[i] = listElements[i].value;
- }
- return listItems;
- }
-
-
- method.addSelectElement = function (element, newItem) {
- this.addOptionToSelect(element, newItem);
- return true;
- }
-
- method.removeCheckBoxElements = function (element, itemsToRemove) {
- return false;
- }
-
- method.removeSelectElements = function (element, itemsToRemove) {
- var items = new Array(itemsToRemove.length);
- for (var i=0;i<itemsToRemove.length;i++) {
- items[itemsToRemove[i]] = true;
- }
-
- var optionList = element.options;
- if (optionList.length > 0) {
- var i = 0;
- var go = true;
- while (go) {
- if (items[optionList[i].value] == true) {
- optionList[i] = null;
- i = 0;
- }
- else {
- i++;
- }
- if (i == optionList.length) {
- go = false;
- }
- }
- }
- return true;
- }
-
- method.clearCheckedFieldValues = function (element) {
- if (element.length) {
- for (var i=0;i<element.length;i++)
- element[i].checked == false;
- }
- else {
- element.checked = false;
- }
- }
-
- method.uncheckCheckBoxGroupValue = function (element) {
- this.clearCheckedFieldValues(element);
- return true;
- }
- method.uncheckRadioGroupValue = function (element) {
- this.clearCheckedFieldValues(element);
- return true;
- }
- method.clearSelectValues = function (element) {
- for (var i=0;i<element.options.length;i++) {
- element.options[i].selected = false;
- }
- return true;
- }
-
- method.getSelectOptionTags = function (newItem) {
- var optionTag = new Array(2);
- if (typeof newItem == 'string') {
- optionTag[0] = optionTag[1] = newItem;
- }
- else {
- optionTag[0] = optionTag[1] = newItem[0];
- if (newItem.length == 2) {
- optionTag[1] = newItem[1];
- }
- }
- return optionTag;
- }
-
- method.setPropertyMap = function (propertyMap) {
- this.propertyMap = propertyMap;
- }
-
- method.getPropertyMap = function () {
- return this.propertyMap;
- }
-
- method.getProperty = function (propertyName) {
- if (this.propertyMap[propertyName]) {
- return this.propertyMap[propertyName];
- }
- return propertyName;
- }
-
- method.getSelectedIndexes = function (objectId){
- var indexList = new Array();
- var j = 0;
-
- var object;
- if ( typeof objectId == "string" )
- object = this.getElementById(objectId);
- else
- return;//\object = objectId;
-
- var elementType = this.getElementType(object);
-
- if (elementType == null) {
- return null;
- }
-
- if (elementType == 'checkbox') {
- for (var i = 0; i < object.options.length; i++){
- if (object.options[i].selected == true) {
- indexList[j] = i;
- if (object.type != 'select-multiple') {
- return i;
- }
- j++;
- }
- }
- return indexList;
- }
-
- else if (elementType == 'radio') {
- for (var i = 0; i < object.options.length; i++){
- if (object.options[i].selected == true)
- return i;
- }
- }
-
- else if (elementType.indexOf('select',0) == 0) {
- for (var i = 0; i < object.options.length; i++){
- if (object.options[i].selected == true) {
- indexList[j] = object.options[i].value;
- if (object.type != 'select-multiple') {
- return i;
- }
- j++;
- }
- }
- return indexList;
- }
- }
- }
-
- HTML.__proto__.Document = NOF_HTML_Doc;
- }
-